package qnb.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import qnb._common.easyui.EasyuiGridData;
import qnb._common.easyui.EasyuiPageVO;
import qnb._common.vo.MessageVOFactory;
import qnb.entity.Nafe;
import qnb.entity.SchoolRoll;
import qnb.service.NafeService;
import qnb.service.SchoolRollService;
import weixinkeji.vip.jweb.power.ann.JWPIdentifiter;

import java.util.List;

/**
 * @author huangxin
 * @date 2019/5/16-14:50
 */
@Controller
@RequestMapping(value = "schoolRoll", produces = "application/json; charset=utf-8")
public class SchoolRollController {
    @Autowired
    private SchoolRollService schoolRollService;

    @RequestMapping("/forward/schoolRoll")
    public ModelAndView forwardToPage(ModelAndView modelAndView) {
        modelAndView.setViewName("schoolRoll/schoolRoll");
        return modelAndView;
    }

    @JWPIdentifiter("schoolRoll:insert")
    @RequestMapping("/add")
    @ResponseBody
    public String add(SchoolRoll schoolRoll) {
        return MessageVOFactory.getAddMessage(schoolRollService.add(schoolRoll));
    }
    @JWPIdentifiter("schoolRoll:delete")
    @PostMapping("/delete")
    @ResponseBody
    public String delete(Integer id) {
        return MessageVOFactory.getDellMessage(schoolRollService.delete(id));
    }

    @JWPIdentifiter("schoolRoll:select")
    @PostMapping("/deleteByIds")
    @ResponseBody
    public String deleteByIds(@RequestParam("ids") List<Integer> ids) {
        return MessageVOFactory.getDellMessage(schoolRollService.deleteByIds(ids));
    }
    @JWPIdentifiter("schoolRoll:update")
    @RequestMapping("/update")
    @ResponseBody
    public String update(SchoolRoll schoolRoll) {

        return MessageVOFactory.getUpdateMessage( schoolRollService.update(schoolRoll));
    }
    @JWPIdentifiter("schoolRoll:select")
    @RequestMapping("/listByPage")
    @ResponseBody
    public EasyuiGridData listByPage(SchoolRoll schoolRoll, EasyuiPageVO vo) {

        return schoolRollService.listByPage(schoolRoll, vo);
    }
    @JWPIdentifiter("schoolRoll:select")
    @RequestMapping("/get")
    @ResponseBody
    public SchoolRoll get(Integer id) {
        return schoolRollService.get(id);
    }

}
